package category

import (
	"supervideo/app/models"
	"supervideo/app/models/zone"
	"supervideo/pkg/database"
)

type Category struct {
	models.BaseModel

	Title    string `json:"title"`
	Sort     int8   `json:"sort,omitempty"`
	Status   int8   `json:"status,omitempty"`
	ZoneID   uint64 `json:"zone_id"`
	ParentID uint64 `json:"parent_id"`

	Zone zone.Zone `json:"zone"`

	models.CommonTimestampsField
}

func (category *Category) Create() {
	database.DB.Create(&category)
}

func (category *Category) Save() (rowAffected int64) {
	result := database.DB.Save(&category)
	return result.RowsAffected
}

func (category *Category) Delete() (rowAffected int64) {
	result := database.DB.Delete(&category)
	return result.RowsAffected
}
